#ifndef __GC_IMAGE_CACHE_H__
#define __GC_IMAGE_CACHE_H__

#include <thread>
#include <string>
#include <iostream>

#include <opencv2/opencv.hpp>
#include "msd/channel.hpp"
#include "cache.hpp"
// #include "lru_cache_policy.hpp"
#include "fifo_cache_policy.hpp"
#include "types.h"
#include "utils_misc.h"

extern GC_APP_CONFIG gc_app_config;
extern caches::fixed_sized_cache<std::string, cv::Mat, caches::FIFOCachePolicy> IMG_CACHE;

typedef struct GCImage {
    char img_path[100];
} GCImage;

using namespace cv;
using namespace std;

namespace gc
{
    class GCImageCache : public Singleton<GCImageCache>
    {
        public:
            GCImageCache();
            virtual ~GCImageCache(void);

            bool Put(const char* img_path, cv::Mat& img);
            bool Put(const char* img_path, cv::Mat& img, bool save_img);
            void Get(const char* img_path, cv::Mat &img);
            bool Remove(const char* img_path);

        private:
            void ClearThrd(void);

        private:
            std::thread m_clear_thread;
            msd::channel<GCImage> m_chan_yuv_image_data;
    };
}
#endif /* __GC_IMAGE_CACHE_H__ */
